package com.whf.android.jar.util.autonavi;

import com.blankj.utilcode.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 高德导航实体类
 *
 * @author whf
 * @date 2021/11/18
 */
public class AutoNavi {

    /**
     * 起点
     */
    public LatLong dropStart;
    /**
     * 终点
     */
    public LatLong dropEnd;

    /**
     * 经纬度信息
     */
    public static class LatLong {
        /**
         * 名称
         */
        public String name = "";
        /**
         * 经度
         */
        public double longitude;
        /**
         * 纬度
         */
        public double latitude;
    }

    public AutoNavi(LatLong dropStart, LatLong dropEnd) {
        this.dropStart = dropStart;
        this.dropEnd = dropEnd;
    }

    public Map<String, String> getAutoNavi() {
        Map<String, String> uriMap = new HashMap<>();
        if (dropStart != null && dropStart.longitude > 0 && dropStart.latitude > 0) {
            if (StringUtils.isEmpty(dropStart.name)) {
                dropStart.name = "起点";
            }
            uriMap.put("slon", "" + dropStart.longitude);
            uriMap.put("slat", "" + dropStart.latitude);
            uriMap.put("sname", dropStart.name);
        }
        if (dropEnd != null && dropEnd.longitude > 0 && dropEnd.latitude > 0) {
            if (StringUtils.isEmpty(dropEnd.name)) {
                dropEnd.name = "终点";
            }
            uriMap.put("dlon", "" + dropEnd.longitude);
            uriMap.put("dlat", "" + dropEnd.latitude);
            uriMap.put("dname", dropEnd.name);
        }
        return uriMap;
    }
}
